using NExt.data;
using NExt.grid;
using NExt.UI.Browse.Data;
using NExt.UI.Find.Data;

namespace NExt.Demo.Application.Entity.Bind
{
    public class FindReference : GridFindPresenter
    {
        protected override DataBrowsePresenter BuildBrowsePresenter()
        {
            DataBrowsePresenter findReferenceBrowse = new FindReferenceBrowse();
            return findReferenceBrowse;
        }
    }

    public class FindReferenceBrowse : GridBrowsePresenter
    {
        protected override ColumnModel BuildColumnModel()
        {
            ColumnModel columnModel = new ColumnModel();
            columnModel.defaultSortable = true;
            columnModel.columns.Add(new RowNumberer());
            columnModel.columns.Add(new Column { header = "Name", dataIndex = "Name", sortable = true });
            columnModel.columns.Add(new Column { header = "LastName", dataIndex = "LastName", sortable = true });
            return columnModel;
        }

        protected override DataReader BuildReader()
        {
            Record record = new Record();
            record.fields.Add(new FieldDefinition { name = "Name", type = FieldDefinitionType.stringg });
            record.fields.Add(new FieldDefinition { name = "LastName", type = FieldDefinitionType.stringg });

            JsonReader reader = new JsonReader();
            reader.recordType = record;

            return reader;
        }

        protected override void FormInitializeComponents()
        {
            base.FormInitializeComponents();
            this.toolbar.hidden = true;
        }
    }
}